import http from 'node:http'
import Cookies from 'cookies'

const sr = http.createServer((req, res) => {
    const cookies = new Cookies(req, res, { /* keys: ['uuid', 'token']  */ })
    req.cookies = cookies
    res.cookies = cookies
    console.log(
        'uuid', req.cookies.get('uuid')
    )
    res.cookies.set('uuid', 'uuiduuiduuiduuiduuid', {
        expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30),
        domain: '.petslib.cn',
        sameSite: '',
        path: '/',
    })
    // console.log(req.)
    // res.setHeader('Set-Cookie', ['type=ninja', 'language=javascript']);

    res.statusCode = 200
    res.setHeader('Content-Type', 'text/html; charset=utf-8')
    res.end(req.cookies.get('type'))

}).listen(3000)

sr.on('error', (err) => {
    console.log('err', err)
})

console.log('http://local.petslib.cn:3000')
